package com.ronan.imweb.listener;

import com.ronan.common.utils.RouteManager;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.stereotype.Component;

/**
 * FileName    : com.withufuture.imweb.listener
 * Description :
 *
 * @author : ronan
 * @version : 1.0
 * Create Date : 2021/3/23 14:02
 **/
@Component
public class IApplicationListener implements ApplicationListener {
    @Override
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        if (applicationEvent instanceof ContextClosedEvent) {
            // 服务器关闭,清空本地所有路由
            RouteManager.removeAll();
        }
    }
}
